package com.datacoper.remotecommands;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;

public abstract class AbstractCommandClient implements ICommandClient {

  private DataInputStream dataInputStream;
  private DataOutputStream dataOutputStream;

  @Override
  public boolean execute(Socket socketClient, String[] args) throws Exception {

    dataInputStream = new DataInputStream(socketClient.getInputStream());

    dataOutputStream = new DataOutputStream(socketClient.getOutputStream());

    dataOutputStream.writeUTF(null);

    String received;

    while (!(received = dataInputStream.readUTF()).equals("FINISH")) {

    }

    return true;
  }

  protected abstract void receive(String received);

  protected abstract String send();

}
